// pages/mine/index/index.js
const app = getApp()
import { toast } from '../../../../utils/Tools'
import { handletabChange } from '../../../utils/Tools'
Page({
  data: {
    userinfo: '',
    list: [],
    isIPhone:false
  },
  onLoad(){
    this.setData({
      userinfo: wx.getStorageSync('driver_user') || '',
      list: app.globalData.list,
      isIPhone: app.globalData.isIPhone
    })
    wx.hideHomeButton()
  },
  //        事件函数          //
  tabChange(e) {
    const {index} = e.detail
    handletabChange(index)
  },
  handleGoto(e){
    wx.reLaunch({
      url: '/driver_side/pages/other/login/login'
    });
  },
  handleOutLogin(e){  //   退出登录
    const {type} = e.currentTarget.dataset
    wx.showModal({
      title: `${type}`,
      content: `是否确认${type}`,
      success: (result) => {
        clearInterval(app.globalData.driverTask)
        if(result.confirm){
          wx.removeStorage({
            key: 'driver_user',
            success: res=>{
              toast(`${type}成功`,'success')
              wx.removeStorageSync('token')
              setTimeout(()=>{
                wx.reLaunch({
                  url: '/driver_side/pages/other/login/login'
                });
              },1500)
            }
          });
        }else{
          toast('取消退出登录')
        }
      }
    });
  }
})  